/**
 * fileName: GridColumnTag.java
 *     Date: 2012-5-1
 **/
package com.stranger.common.tag.grid;




import javax.servlet.jsp.JspException;
import javax.servlet.jsp.tagext.Tag;
import javax.servlet.jsp.tagext.TagSupport;




/**
 * @作者 stranger.lin
 *
 * @时间 2012-5-1
 */
public class GridColumnTag extends TagSupport {

	/**
	 * 
	 */
	private static final long serialVersionUID = 5217332551482970259L;
	private String name;//列明
	private String headerName; //列的中文名称
	private int with;//列的宽度
	private String align;//列位置
	private String hidden;//列是否隐藏
	private String colNames;
	private String colModel;
	private String jsonmap;
	private String sortable;
	
	@Override
	public int doStartTag() throws JspException {
		Tag flg= findAncestorWithClass(this, GridTag.class);
		if (flg==null) {
			throw new JspException("cloumn标签必须放在grid标签里");
		}
		if (name==null) {
			throw new JspException("列明不能为空");
		}
		GridTag grid=(GridTag)flg;
		
		Column column=new Column();
		column.setName(name);
		column.setHeaderName(headerName);
		column.setAlign(align);
		column.setHidden(hidden);
		column.setWith(with);
		column.setJsonmap(jsonmap);
		column.setSortable(sortable);
		
		grid.getColumns().add(column);
		
		
		clearPropery();
		return SKIP_BODY;
	}

	
	
	@Override
	public int doEndTag() throws JspException {
		
		return EVAL_PAGE;
	}

	
	private void clearPropery(){
		name=null;//列明
		headerName=null; //列的中文名称
		with=0;//列的宽度
		align=null;//列位置
		hidden=null;//列是否隐藏
		colNames=null;
		colModel=null;
		jsonmap=null;
	}




	public String getName() {
		return name;
	}



	public void setName(String name) {
		this.name = name;
	}



	public String getHeaderName() {
		return headerName;
	}



	public void setHeaderName(String headerName) {
		this.headerName = headerName;
	}



	public int getWith() {
		return with;
	}



	public void setWith(int with) {
		this.with = with;
	}



	public String getAlign() {
		return align;
	}



	public void setAlign(String align) {
		this.align = align;
	}



	public String getHidden() {
		return hidden;
	}



	public void setHidden(String hidden) {
		this.hidden = hidden;
	}



	public String getColNames() {
		return colNames;
	}



	public void setColNames(String colNames) {
		this.colNames = colNames;
	}



	public String getColModel() {
		return colModel;
	}



	public void setColModel(String colModel) {
		this.colModel = colModel;
	}

	public String getJsonmap() {
		return jsonmap;
	}

	public void setJsonmap(String jsonmap) {
		this.jsonmap = jsonmap;
	}



	public String getSortable() {
		return sortable;
	}



	public void setSortable(String sortable) {
		this.sortable = sortable;
	}

	

}
